import type { PageType } from '../../../lib/page_handler/type'
import type { ModulePlatformConfig } from '../types'
import { GreasyForkPageType } from '../../../lib/page_handler/platform/greasyfork/types'
import { SUPPORTED_PLATFORMS } from '../../../types/constants'
import { EffectType, SYMBOLS } from '../../../types/interfaces'
import { AppModule } from '../types'

export function getDataPresentationModules(pageType: PageType): ModulePlatformConfig {
  return {
    [AppModule.GreasyForkStatsPanel.id]: {
      meta: {
        name: '油叉面板',
        description: '通过图表展示用户在油叉脚本页面上的标记数据，包括脚本、反馈和用户标记',
        category: 'dataPresentation',
        icon: `${SYMBOLS.DOCUMENTS.SCROLL}${SYMBOLS.UI.CHART}`,
        status: 'not-needed',
        defaultEnabled: true,
        effectType: EffectType.IMMEDIATE,
      },
      supportedPlatforms: {
        [SUPPORTED_PLATFORMS.GREASY_FORK]: {
          status: 'supported',
          pageTypeValidator: () => {
            const supportPages = [
              GreasyForkPageType.SCRIPT_STATS,
            ]
            return supportPages.includes(pageType as GreasyForkPageType)
          },
        },
      },
    },
    [AppModule.DiscussionAnalytics.id]: {
      meta: {
        name: '对话分析',
        description: '可视化参与度、用户活跃度、时间分布等维度（不支持自动刷新）',
        category: 'dataPresentation',
        icon: `${SYMBOLS.OTHERS.COMMENT}${SYMBOLS.UI.CHART}`,
        status: 'not-needed',
        defaultEnabled: true,
        effectType: EffectType.IMMEDIATE,
      },
      supportedPlatforms: {
        [SUPPORTED_PLATFORMS.GREASY_FORK]: {
          status: 'supported',
          description: '可视化参与度、用户活跃度、时间分布等维度（不支持自动刷新，位置在订阅按钮左边）',
          pageTypeValidator: () => {
            const supportPages = [
              GreasyForkPageType.SCRIPT_DISCUSSION,
              GreasyForkPageType.DISCUSSIONS_DETAIL,
            ]
            return supportPages.includes(pageType as GreasyForkPageType)
          },
        },
      },
    },
    [AppModule.FloorMarker.id]: {
      meta: {
        name: '论坛对话',
        description: '标注楼层，区分对话方向，突出楼主与作者评论，提升浏览体验。',
        category: 'dataPresentation',
        icon: `${SYMBOLS.OTHERS.COMMENT}${SYMBOLS.OTHERS.ROCKET}`,
        status: 'not-needed',
        defaultEnabled: true,
        effectType: EffectType.IMMEDIATE,
      },
      supportedPlatforms: {
        [SUPPORTED_PLATFORMS.GREASY_FORK]: {
          status: 'supported',
          pageTypeValidator: () => {
            const supportPages = [
              GreasyForkPageType.SCRIPT_DISCUSSION,
              GreasyForkPageType.DISCUSSIONS_DETAIL,
            ]
            return supportPages.includes(pageType as GreasyForkPageType)
          },
        },
      },
    },
    [AppModule.TimeInterval.id]: {
      meta: {
        name: '回复间隔',
        description: '显示相邻两条消息之间的时间间隔',
        category: 'dataPresentation',
        icon: `${SYMBOLS.OTHERS.COMMENT}${SYMBOLS.TIME.CLOCK}`,
        status: 'not-needed',
        defaultEnabled: true,
        effectType: EffectType.IMMEDIATE,
      },
      supportedPlatforms: {
        [SUPPORTED_PLATFORMS.GREASY_FORK]: {
          status: 'supported',
          pageTypeValidator: () => {
            const supportPages = [
              GreasyForkPageType.SCRIPT_DISCUSSION,
              GreasyForkPageType.DISCUSSIONS_DETAIL,
            ]
            return supportPages.includes(pageType as GreasyForkPageType)
          },
        },
      },
    },
    [AppModule.UserAnalytics.id]: {
      meta: {
        name: '用户分析',
        description: '可视化分析用户脚本与评论数据',
        category: 'dataPresentation',
        icon: `${SYMBOLS.USER.USER_CENTER}${SYMBOLS.UI.CHART}`,
        status: 'not-needed',
        defaultEnabled: true,
        effectType: EffectType.IMMEDIATE,
      },
      supportedPlatforms: {
        [SUPPORTED_PLATFORMS.GREASY_FORK]: {
          status: 'supported',
          pageTypeValidator: () => {
            const supportPages = [
              GreasyForkPageType.USER_PROFILE,
            ]
            return supportPages.includes(pageType as GreasyForkPageType)
          },
        },
      },
    },
  }
}
